from rest_framework import serializers
from .models import Area


class AreasSerializer(serializers.ModelSerializer):
    """
    行政区划列表的序列化器
    """
    class Meta:
        model = Area
        fields = ['id', 'name']


class AreaSerializer(serializers.ModelSerializer):
    subs = AreasSerializer(many=True)

    class Meta:
        model = Area
        fields = ['id', 'name', 'subs']
